<?php
function PMA_sanitize($message) { $replace_pairs = array( '<' => '&lt;', '>' => '&gt;', '[i]' => '<em>', '[/i]' => '</em>', '[em]' => '<em>', '[/em]' => '</em>', '[b]' => '<strong>', '[/b]' => '</strong>', '[strong]' => '<strong>', '[/strong]' => '</strong>', '[tt]' => '<code>', '[/tt]' => '</code>', '[code]' => '<code>', '[/code]' => '</code>', '[kbd]' => '<kbd>', '[/kbd]' => '</kbd>', '[br]' => '<br />', '[/a]' => '</a>', '[sup]' => '<sup>', '[/sup]' => '</sup>', ); $message = strtr($message, $replace_pairs); $pattern = '/\[a@([^"@]*)@([^]"]*)\]/'; if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) { $valid_links = array( 'http', './Do', ); foreach ($founds as $found) { if (! in_array(substr($found[1], 0, 4), $valid_links)) { return $message; } if (! empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) { return $message; } } $message = preg_replace($pattern, '<a href="\1" target="\2">', $message); } return $message; } ?>
